<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>管理员登陆</title>
	<link rel="icon" href="../../img/icon.png" type="image/x-icon"/>
	<link rel="stylesheet" type="text/css" href="../../css/mui.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/app.css"/>
</head>
<body>
<!-- 顶部菜单 -->
<ul id="top">
	<li class="addBug back" onclick="mui.back();">返回</li>
	<li class="addBug">管理员登陆</li>
	<li class="addBug pub">&nbsp;</li>
</ul>
<!-- 主体 -->
<div style="height: 50px;"></div>
<div class="form">
	<h2>登陆</h2>
	<input type="text" id="adminName" placeholder="管理员昵称" value=""/>
	<input type="password" id="adminPwd" placeholder="登陆密码" value=""/>
	<input type="button"  value="保存" onclick="setLogin()"/>
</div>
<div style="height: 50px;"></div>
<!-- 底部菜单 -->
<ul id="foot">
	<li class="noclick" onclick="jumpToIndex()">BUG</li>
	<li class="noclick" onclick="jumpToHistory()">历史</li>
	<li class="noclick" onclick="jumpToMore()">更多</li>
	<li class="noclick" onclick="jumpToMy()">我的</li>
</ul>
</body>
</html>


<!-- <script type="text/javascript" src="../../js/mui.js"></script> -->
<script type="text/javascript" src="../../js/mui.min.js"></script>
<script type="text/javascript" src="../../js/app.js"></script>
<script type="text/javascript">
	// MUI页面初始化函数
	mui.init({
	  /*设置各种手势操作的开关*/
		gestureConfig:{
		tap: true, //默认为true
		doubletap: true, //默认为false
		longtap: true, //默认为false
		wipe: true, //默认为true
		drag: true, //默认为true
		hold:false,//默认为false，不监听
		release:false//默认为false，不监听
		}
	});
	// (function($, owner) {
	// }(mui, window.app = {}));
	//管理员登陆
	function setLogin(){
		var domain = getDomain();
		var adminName = mui("#adminName")[0].value;
		var adminPwd = mui("#adminPwd")[0].value;
		if (!adminName || !adminPwd) {
			mui.toast('昵称或密码没填写！',{ 
				duration:'long', type:'div',
			});
			return
		}
		// console.log(adminName,adminPwd); return
		mui.ajax(domain+'/app/login',{
			data:{
				name:adminName,
				pwd:adminPwd
			},
			dataType:'json',//服务器返回json格式数据
			type:'post',//HTTP请求类型
			timeout:10000,//超时时间设置为10秒；
			// headers:{'Content-Type':'application/json'},
			headers:{'Content-Type':'application/x-www-form-urlencoded'}, 
			async: true,  //async: true || false, // 异步 || 同步
			crossDomain: true,  //强制跨域
			success:function(res){
				console.log(res); 
				// return
				if (res.code!=0) {
					mui.toast(res.msg+'！',{ 
						duration:'long', type:'div',
					});
					return
				}
				//TOKEN存入缓存
				cacheSet(adminTokenKey, res.data.token);
				var adminInfo = {
					'adminId':res.data.adminInfo.adminId,
					'adminName':res.data.adminInfo.adminName,
					'genre':res.data.adminInfo.genre,
					'genreName':res.data.adminInfo.genreName,
					'head':res.data.adminInfo.head,
					'createTime':res.data.adminInfo.createTime,
				};
				cacheSet(adminInfoKey, adminInfo);
				//成功提示
				mui.toast('登陆成功！',{ 
					duration:'long', type:'div',
				});
				//页面跳转至首页
				setTimeout(function(){
					jumpToIndex();
				}, 3000);
			},
			error:function(xhr,type,errorThrown){
				// console.log('网络错误');
				mui.toast(xhr+type+'网络错误！',{
					duration:'long', type:'div',
				});
			}
		});
	}
</script>